home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Newton Sample Code 1.1 / Utility Functions / LondonCalling-2 / README.London Calling < prev   
Encoding:
Text File  |  1994-02-28  |  4.1 KB  |  129 lines  |  [TEXT/R*ch]

  1. London Calling, by Maurice Sharp
  2. Copyright (c) 1993-94 Apple Computer, Inc.  All rights reserved.
  3.  
  4. This sample shows how to get a modified phone number string based on
  5. the user settings in the Newt. It also shows how to bring up the Options
  6. dialog (as in the CallingSlip).
  7.  
  8. The Sample
  9. ----------
  10.  
  11. This section points you to the important parts of the London Calling sample.
  12. You may want to skip this section and read the System Calls and Data section
  13. first since it explains the mechanisms in detail.
  14.  
  15. There are really only *** important parts to the sample...
  16.  
  17. **** myBase.UpdatePhone - method ****
  18.  
  19. This is where all the 'work' happens. It is a simple call to MungePhone
  20. embedded in a SetValue statement (so that the staticText that is the
  21. new phone number gets updated).
  22.  
  23. **** myBase.countryList ****
  24.  
  25. This is a protoTextList that is used to set the country of origin for
  26. the phone number in the phoneLine protoLabelInputLine.
  27.  
  28. **** myBase.countryList.viewSetupFormScript / listItems ****
  29.  
  30. the viewSetupFormScript sets up the listItems array used by protoTextList
  31. to construct the list of items (really...)
  32.  
  33. It is set up by looking at ROM_countries (see below)
  34.  
  35. **** Convert button ****
  36.  
  37. This is actually a simple one. The buttonClickScript calls UpdatePhone
  38.  
  39. **** Options button ****
  40.  
  41. This is where I bring up the call options slip. The buttonClickScript
  42. does 2 things, first set the invoker slot of the callOptionsSlip, then
  43. toggles it. See below for more info on callOptionsSlip
  44.  
  45.  
  46. System Calls and Data
  47. ---------------------
  48.  
  49.  
  50. **** :MungePhone(<phone-string>, <origin-country>); ****
  51.  
  52. This is the main method that you call to convert find the correct dialing
  53. sequence. It is a method of the root view (i.e., GetRoot()).
  54.  
  55. RETURNS a string that is the phone number to dial based on the users
  56. location and other options (like long distance prefix, ...)
  57.  
  58. <phone-string> is the phone number to convert. It should generally be of
  59.                the form <area-code> <phone-number>
  60.                
  61.                e.g., 415 555 1212 - a phone number in San Fran
  62.                         81 555 1212 - a phone number in London, UK
  63.  
  64. <origin-country> a string that specifies the country of origin of
  65.                  the phone number in <phone-string>.
  66.                 
  67.                 e.g., "USA" for "415 555 1212"
  68.                       "UK" fo "81 555 1212"
  69.                       
  70.                 NOTE: the country MUST be one from ROM_countries (see below)
  71.                 
  72. Some examples for the inspector...
  73. Use the Newton to set your TimeZone to Cupertino
  74.  
  75. GetRoot():MungePhone("408 555 1212", "USA");
  76. #441A751  " 555 1212"
  77.  
  78. GetRoot():MungePhone("415 555 1212", "USA");
  79. #4410189  " 1 415 555 1212"
  80.  
  81. GetRoot():MungePhone("81 555 1212", "UK");
  82. #440F8E1  "  011 44 81 555 1212"
  83.  
  84. // Now go and set your TimeZone to London England
  85. GetRoot():MungePhone("408 555 1212", "USA");
  86. #440A7B9  "  010 1 408 555 1212"
  87.  
  88. GetRoot():MungePhone("415 555 1212", "USA");
  89. #440AC41  "  010 1 415 555 1212"
  90.  
  91. for fun you can try and set options in from the call slip (open up the
  92. cardfile and click on a telephone number, then click options). Check out
  93. how that modifies the return from MungePhone.
  94.  
  95.  
  96. **** ROM_countries ****
  97.  
  98. This is a frame that has one slot for each country that Newton can
  99. convert phone numbers for. Each slot is a frame, the only slot you
  100. care about is the name slot.
  101.  
  102. You can get an array of the names of all known countries like this:
  103.  
  104. local countryNames := foreach item in ROM_countries collect item.name ;
  105.  
  106.  
  107. **** callOptionsSlip ****
  108.  
  109. This is the sytem slip for getting and setting the user call options. This
  110. includes the current area code, dialing prefix, long distance access code and
  111. any calling card numbers the user may have.
  112.  
  113. MungePhone automatically checks these user configuration items, so they will
  114. be figured into the return string.
  115.  
  116. However, you may want to allow the user to set these up, so you will need to
  117. open the callOptionsSlip.
  118.  
  119. This is actually very easy. You need to do 2 things:
  120.  
  121.     1. Set the invoker slot in the callOptionsSlip to your application view
  122.     2. add an UpdatePhone method to your application view
  123.     
  124. UpdatePhone()
  125.  
  126. This method is called by callOptionSlip when it is closed or hidden.
  127. You should update whatever call string you have generated with another
  128. call to MungePhone.
  129.